#include <stdio.h>
#include <stdlib.h>
#include "string.h"
#include "math.h"

#include "doge-cmd-parser.h"


void led_cmd_callback(int argc, char **argv)
{
    int i = 0;

    printf("argc = %d\r\n", argc);
    for (i = 0; i < argc; i++)
        printf("argv[%d] = %s\t", i, argv[i]);

    printf("\r\n");
}

void freq_cmd_callback(int argc, char **argv)
{
    int i = 0;

    printf("argc = %d\r\n", argc);
    for (i = 0; i < argc; i++)
        printf("argv[%d] = %s\t", i, argv[i]);

    printf("\r\n");

    int num1 = atoi(argv[1]);
    int num2 = atoi(argv[2]);
    printf("num1 = %d num2 = %d\r\n", num1, num2);
}

dcmd_list_t  d_cmd_list[] = {
	{.cmd = "LED", .cb = led_cmd_callback},
	{.cmd = "FREQ", .cb = freq_cmd_callback},
};

int _str_cmp(char *str1, char *str2);

int main(void)
{
	char buf[] = "             LED 20 20 30 6 8";
	char buf1[] = " FREQ 5 3";

	doge_cmd_parser(buf, d_cmd_list, _DCMD_LIST_COUNTOF(d_cmd_list));

	doge_cmd_parser(buf1, d_cmd_list, _DCMD_LIST_COUNTOF(d_cmd_list));

#if 0
	if (_str_cmp(buf, "LED 20 20") == 0)
	{
		printf("aaa\r\n");
	}
	else
	{
		printf("bbb\r\n");
	}
#endif
	return 0;
}
